package com.gxa.service.impl;

import com.gxa.mapper.StorageManageMapper;
import com.gxa.service.StorageManageService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 陈静
 * @date 2020/9/27 16:54
 */
@Service(value = "storageManageService")
public class StorageManageServiceImpl implements StorageManageService {
    @Resource
    StorageManageMapper storageManageMapper;


    /**
     *  查询品牌名称
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public List<Map<String, Object>> findBrandName() {
        return storageManageMapper.findBrandName();
    }

    /**
     *  查询所有的分类名称
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public List<Map<String, Object>> findLevelName() {
        return storageManageMapper.findLevelName();
    }

    /**
     *
     * @param map 根据商品名称或者商品类型或者商品品牌查询
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public List<Map<String, Object>> findStorageManage(Map<String, Object> map) {
        return storageManageMapper.findStorageManage(map);
    }
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public Integer countFindStorageManage(Map<String, Object> map) {
        return storageManageMapper.countFindStorageManage(map);
    }

    /**
     * 根据id查询库存信息
     * @param id
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public List<Map<String, Object>> findStorageManageById(Integer id) {
        return storageManageMapper.findStorageManageById(id);
    }

    /**
     * 根据id删除库存管理信息
     * @param id
     * @return
     */
    @Transactional(propagation =Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public Integer deleteStorageManageById(Integer id) {
        return storageManageMapper.deleteStorageManageById(id);
    }

    /**
     *
     * @param start 起始页
     * @param pageSize 分页大小
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public List<Map<String, Object>> findAllStorageManage(Integer start, Integer pageSize) {
        return storageManageMapper.findAllStorageManage(start,pageSize);
    }


    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public Integer countFindAllStorageManage() {
        return storageManageMapper.countFindAllStorageManage();
    }

    /**
     *  修改库存管理信息
     * @param map
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class)
    @Override
    public Integer updateStorageManage(Map map) {
        return storageManageMapper.updateStorageManage(map);
    }
}
